﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Configuration;

namespace Logistics_Management_System.Customer_Employee_Permission
{
    public class Employee_Repository : ServiceBase
    {
        public LG_Employee GetEmployeeById(int emp_id)
        { return (from emp in this.DB.LG_Employees where emp.Id == emp_id select emp).FirstOrDefault<LG_Employee>(); }
        public List<LG_Employee> GetEmployeesByBranchId(int branch_id)
        { return (from emps in this.DB.LG_Employees where emps.Branch_Id == branch_id select emps).ToList<LG_Employee>(); }

        public LG_Employee GetEmployeeByUsername(string username)
        { return (from emp in this.DB.LG_Employees where emp.Username == username select emp).FirstOrDefault<LG_Employee>(); }

        public string encodeMd5(string text_for_encode)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bs = System.Text.Encoding.UTF8.GetBytes(text_for_encode);
            bs = x.ComputeHash(bs);
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            foreach (byte b in bs)
            {
                s.Append(b.ToString("x2").ToLower());
            }
            string password = s.ToString();
            return password;
        }
    }
}